package top.hkyzf.util;

import net.minecraft.client.Minecraft;
import top.hkyzf.event.TickEvents;
import top.hkyzf.util.movement.OneKeyInput;

import java.util.HashMap;
import java.util.Map;

/**
 * description: 当前 MOD 的上下文环境
 * @author zhufeng
 * @date 2022/8/19 17:48
 * @version V1.0
 */
public class OneKeyContext {
    /**
     * MOD 运行过程中唯一的各种上下文环境
     */
    private static final OneKeyContext CONTEXT = new OneKeyContext();
    /**
     * 判断是否已经在游戏中
     */
    private TickEvents.Type inTheWorld = TickEvents.Type.OUT;

    /**
     * 是否是 AI 在控制
     */
    private volatile boolean inControl = false;

    /**
     * 强制停止挂机标志
     */
    private volatile boolean forceStop = false;

    /**
     * 我的世界主体实例
     */
    private final Minecraft mc = Minecraft.getInstance();

    /**
     * 储存当前 AI 按键是否被按下
     */
    private final Map<OneKeyInput, Boolean> inputPressDownMap = new HashMap<>();


    /**
     * 获取单例对象
     * @return MOD 上下文环境
     */
    public static OneKeyContext getInstance() {
        return CONTEXT;
    }

    public TickEvents.Type getInTheWorld() {
        return inTheWorld;
    }

    public void setInTheWorld(TickEvents.Type inTheWorld) {
        this.inTheWorld = inTheWorld;
    }

    public boolean isInControl() {
        return inControl;
    }

    public void setInControl(boolean inControl) {
        this.inControl = inControl;
    }

    public boolean isForceStop() {
        return forceStop;
    }

    public void setForceStop(boolean forceStop) {
        this.forceStop = forceStop;
    }

    public Minecraft getMc() {
        return mc;
    }

    public Map<OneKeyInput, Boolean> getInputPressDownMap() {
        return inputPressDownMap;
    }
}
